package cc.yihy.spider.core;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.downloader.HttpClientDownloader;

/**
 * @Package: cc.yihy.util
 * @date: 2017/11/22 23:43
 * @author: Yihy
 * @version: V1.0
 * @Description:
 */
public class NewHttpClientDownloader extends HttpClientDownloader {
    @Override
    public Page download(Request request, Task task) {
        String url = request.getUrl();

        if (url.indexOf("recommendations") != -1 || url.indexOf("public_notes") != -1) {
            request.addHeader("Accept", "application/json");
        }
        return super.download(request, task);
    }
}
